﻿using System.Net;
using System.Text;

namespace H.Sync.Http
{
    /// <summary>
    /// HTTP 返回结果
    /// </summary>
    public class HttpResult
    {
        /// <summary>
        /// Http 状态码
        /// </summary>
        public HttpStatusCode? StatusCode { get; set; }

        /// <summary>
        /// 反馈的内容
        /// </summary>
        public byte[] Content { get; set; }

        /// <summary>
        /// 编码类型
        /// </summary>
        public Encoding EncodingType { get; }

        public HttpResult(Encoding encoding)
        {
            EncodingType = encoding;
        }

        /// <summary>
        /// 反馈的内容的字符串表示(将根据EncodingType进行编码)
        /// </summary>
        public string ContentStr => Content != null ? EncodingType.GetString(Content) : null;

        /// <summary>
        /// 错误信息
        /// </summary>
        public string Errmsg { get; set; }
    }
}
